import request from '@/utils/request'

export function getRolePage(params) {
    return request({
        url: `/api/v1/core/role/page`,
        method: 'post',
        data: params
    })
}

export function getRoleList(params) {
    return request({
        url: `/api/v1/core/role/list`,
        method: 'post',
        data: params
    })
}

export function addRole(params) {
    return request({
        url: `/api/v1/core/role/add`,
        method: 'post',
        data: params
    })
}

export function updateRole(params) {
    return request({
        url: `/api/v1/core/role/update`,
        method: 'post',
        data: params
    })
}

export function deleteRole(params) {
    return request({
        url: `/api/v1/core/role/delete?id=${params.id}&isforce=${params.isforce}`,
        method: 'get'
    })
}

export function getRolePermissionRelList(params) {
    return request({
        url: `/api/v1/core/role/permission/rel/list?roleId=${params.roleId}`,
        method: 'get'
    })
}

export function getRoleOwnerMenuList(params) {
    return request({
        url: `/api/v1/core/menu/list/by/role/id?roleId=${params.roleId}`,
        method: 'get'
    })
}

export function setRolePermissionRel(params) {
    return request({
        url: `/api/v1/core/role/change/permission/rel`,
        method: 'post',
        data: params
    })
}

export function getRoleIdsByOrgId(params) {
    return request({
        url: `/api/v1/core/role/org/rel/role/list?orgId=${params.orgId}`,
        method: 'get'
    })
}

export function setOrgRoleRel(params) {
    return request({
        url: `/api/v1/core/role/org/alloc/role`,
        method: 'post',
        data: params
    })
}

export function getRoleIdsByPostId(params) {
    return request({
        url: `/api/v1/core/role/post/rel/role/list?postId=${params.postId}`,
        method: 'get'
    })
}

export function setPostRoleRel(params) {
    return request({
        url: `/api/v1/core/role/post/alloc/role`,
        method: 'post',
        data: params
    })
}

export function getRoleIdsByUserId(params) {
    return request({
        url: `/api/v1/core/role/user/rel/role/list?userId=${params.userId}`,
        method: 'get'
    })
}

export function setUserRoleRel(params) {
    return request({
        url: `/api/v1/core/role/user/alloc/role`,
        method: 'post',
        data: params
    })
}
